package com.ruoyi.game.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.game.domain.MetaverseGame;
import com.ruoyi.game.service.IMetaverseGameService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 游戏管理Controller
 * 
 * @author ruoyi
 * @date 2023-10-18
 */
@RestController
@RequestMapping("/metaverse-game/game")
public class MetaverseGameController extends BaseController
{
    @Autowired
    private IMetaverseGameService metaverseGameService;

    /**
     * 查询游戏管理列表
     */
    @PreAuthorize("@ss.hasPermi('metaverse-game:game:list')")
    @GetMapping("/list")
    public TableDataInfo list(MetaverseGame metaverseGame)
    {
        startPage();
        List<MetaverseGame> list = metaverseGameService.selectMetaverseGameList(metaverseGame);
        return getDataTable(list);
    }

    /**
     * 导出游戏管理列表
     */
    @PreAuthorize("@ss.hasPermi('metaverse-game:game:export')")
    @Log(title = "游戏管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MetaverseGame metaverseGame)
    {
        List<MetaverseGame> list = metaverseGameService.selectMetaverseGameList(metaverseGame);
        ExcelUtil<MetaverseGame> util = new ExcelUtil<MetaverseGame>(MetaverseGame.class);
        util.exportExcel(response, list, "游戏管理数据");
    }

    /**
     * 获取游戏管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('metaverse-game:game:query')")
    @GetMapping(value = "/{gameId}")
    public AjaxResult getInfo(@PathVariable("gameId") Long gameId)
    {
        return success(metaverseGameService.selectMetaverseGameByGameId(gameId));
    }

    /**
     * 新增游戏管理
     */
    @PreAuthorize("@ss.hasPermi('metaverse-game:game:add')")
    @Log(title = "游戏管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MetaverseGame metaverseGame)
    {
        return toAjax(metaverseGameService.insertMetaverseGame(metaverseGame));
    }

    /**
     * 修改游戏管理
     */
    @PreAuthorize("@ss.hasPermi('metaverse-game:game:edit')")
    @Log(title = "游戏管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MetaverseGame metaverseGame)
    {
        return toAjax(metaverseGameService.updateMetaverseGame(metaverseGame));
    }

    /**
     * 删除游戏管理
     */
    @PreAuthorize("@ss.hasPermi('metaverse-game:game:remove')")
    @Log(title = "游戏管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{gameIds}")
    public AjaxResult remove(@PathVariable Long[] gameIds)
    {
        return toAjax(metaverseGameService.deleteMetaverseGameByGameIds(gameIds));
    }
}
